home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-01 | 4.9 KB | 193 lines | [TEXT/CWIE] |
- /*
- File: CDimmerApp.cp
-
- Contains: A test harness for the dimmer stuff. See Dimmer.rsrc
- for the way to use Constructor to define the panes.
-
- Written by: Sak Wathanasin
- Network Analysis Ltd
- 178 Wainbody Ave South
- Coventry CV3 6BX
- UK
- Phone: (+44) 203 419996
- E-mail: sw@network-analysis-ltd.co.uk
-
- Copyright: © 1995 Network Analysis Ltd. All rights reserved.
-
- Change History (most recent first):
-
- <1.0> 07/08/95 sw First release.
-
- To Do:
- */
-
-
- #include "CDimmerApp.h"
- #include "CDimmerCluster.h"
-
- #include <LWindow.h>
- #include <LRadioGroup.h>
- #include <LStdControl.h>
- #include <LButton.h>
-
- #include <PP_Messages.h>
- #include <UDrawingState.h>
- #include <URegistrar.h>
- #include <UReanimator.h>
- #include <LGrowZone.h>
- #include <UMemoryMgr.h>
-
- const MessageT cmd_OpenDimmerDlg = 3000;
-
- const ResIDT rDimmerDlgID = 1000;
- const ResIDT rRidLDimmerControls = 1001;
-
- const ResIDT rOK = 'BtOK';
- const ResIDT rCancel = 'BtCn';
- const ResIDT rDimmerViewID = 'topV';
- const ResIDT rEnableCBID = 'CBEn';
-
-
- const MessageT cDisableCluster = 5000;
-
-
- // ===========================================================================
- // • Main Program
- // ===========================================================================
-
- void main(void)
- {
- // Set Debugging options
- SetDebugThrow_(debugAction_Alert);
- SetDebugSignal_(debugAction_Alert);
-
- InitializeHeap(4);
- UQDGlobals::InitializeToolbox(&qd);
- new LGrowZone(20000);
-
- CDimmerApp theApp;
- theApp.Run();
- }
-
-
- // ---------------------------------------------------------------------------
- // • CDimmerApp
- // ---------------------------------------------------------------------------
- // Constructor
-
- CDimmerApp::CDimmerApp()
- {
- // Register functions to create core PowerPlant classes
-
- URegistrar::RegisterClass(LWindow::class_ID, LWindow::CreateWindowStream);
- URegistrar::RegisterClass(LDialogBox::class_ID, LDialogBox::CreateDialogBoxStream);
- URegistrar::RegisterClass(LStdButton::class_ID, LStdButton::CreateStdButtonStream);
- URegistrar::RegisterClass(LStdCheckBox::class_ID, LStdCheckBox::CreateStdCheckBoxStream);
- URegistrar::RegisterClass(LStdRadioButton::class_ID, LStdRadioButton::CreateStdRadioButtonStream);
- URegistrar::RegisterClass(LButton::class_ID, LButton::CreateButtonStream);
- URegistrar::RegisterClass(LCaption::class_ID, LCaption::CreateCaptionStream);
- URegistrar::RegisterClass(LRadioGroup::class_ID, LRadioGroup::CreateRadioGroupStream);
- URegistrar::RegisterClass(LEditField::class_ID, LEditField::CreateEditFieldStream);
- URegistrar::RegisterClass(LStdPopupMenu::class_ID, LStdPopupMenu::CreateStdPopupMenuStream);
-
- // Register the functions to create our custom Pane classes
-
- URegistrar::RegisterClass(CDimmerCluster::class_ID, CDimmerCluster::CreateDimmerStream);
- URegistrar::RegisterClass(CDimmableEditText::class_ID, CDimmableEditText::CreateDimmableEditTextStream);
- URegistrar::RegisterClass(CDimCaption::class_ID, CDimCaption::CreateDimCaptionStream);
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~CDimmerApp
- // ---------------------------------------------------------------------------
- // Destructor
- //
-
- CDimmerApp::~CDimmerApp()
- {
- }
-
- // ---------------------------------------------------------------------------
- // • StartUp
- // ---------------------------------------------------------------------------
- // This function lets you do something when the application starts up. We'll
- // bring up the Standard Controls window.
- //
-
- void
- CDimmerApp::StartUp()
- {
- ObeyCommand(cmd_OpenDimmerDlg, nil);
- }
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand
- // ---------------------------------------------------------------------------
- // This function handles menu commands.
- //
-
- Boolean
- CDimmerApp::ObeyCommand(
- CommandT inCommand,
- void *ioParam)
- {
- Boolean cmdHandled = true;
- LDialogBox *theWindow;
- LEditField *theText;
-
- switch (inCommand) {
-
- case cmd_OpenDimmerDlg:
- theWindow = (LDialogBox*)LWindow::CreateWindow(rDimmerDlgID, this);
-
- // set up text field as the initial target
- theText = (LEditField*)theWindow->FindPaneByID('edt1');
- theWindow->SetLatentSub(theText);
-
- theWindow->Show();
- break;
-
- default:
- cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus
- // ---------------------------------------------------------------------------
- // This function enables menu commands.
- //
-
- void
- CDimmerApp::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
-
- switch (inCommand) {
-
- case cmd_Open:
- case cmd_New:
- outEnabled = false;
- break;
-
- case cmd_OpenDimmerDlg:
- outEnabled = true;
- break;
-
- default:
- LApplication::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-